<?
$rightCol = 1;
include('includes/appInit.php');
$access  = new accountAccess();
$errorDivDisplay = 'none';
/*
 * Are we already logged in?
 */
if ($_SESSION['logged'] == 1) {
	header('Location: accountHome.php');
}

/*
 * Are we attempting to log in?
 */
if ($_GET['login'] == 1) {
	$email = $_POST['email'];
	if (!$access->checkLogin($email)) {
		$error = 1;
		$errorMessage = 'Oops! There is a problem with your login.';
		$errorDivDisplay = '';
	} else {
		header('Location: accountHome.php');
	}
}
if ($_GET['logout'] == 1) {
	$access->logout();
}

include('includes/header.php');
?>
	<div id="subPage">
		<div class="leftCol">
		
			<div id="subPageContent" class="flex">
				<h1><?=$translate->_('Account Login'); ?></h1>
				<p>Please login to your Child Disability Connection account by entering your
				email address below.</p>
				
				<div style="height: 20px;"></div>
				<div id="errorMessage" class="errorMessageBig" style="display: <?=$errorDivDisplay; ?>;"><?=$errorMessage; ?></div>
				<? if ($error == 1) { ?>
				<p>Some possible reasons are:</p>
				<ul class="normalUL">
					<li>You don't have an account. <a href="accountCreate.php">Create your account here.</a></li>
					<li>You typed your email address incorrectly. Please try again.</li>
				</ul>
				<p>If you have any questions, please contact our <a href="mailto:<?=MASTER_MAIL; ?>">Helpdesk</a>.</p>
				<? } ?>
				<div style="height: 20px;"></div>
				<form action="<?=$_SERVER['PHP_SELF']; ?>?login=1" method="POST">
					<p><label class="required">Enter your email address</label>
					<input type="text" style="width: 310px;" name="email" id="email" value="<?=$email; ?>" />
					</p>
					<div style="margin-left: 250px;">
					<input type="submit" value="<? echo $translate->_('Login'); ?>" class="buttonSearch" title="<? echo $translate->_('Login'); ?>" />
					</div>		
				</form>
			</div>
		</div>
		<div class="rightCol noPrint">
			<div class="rightColInner flex" style="height: 500px;">
				<? include('includes/rightColumn.php'); ?>
			</div>
		</div>
		<div style="clear: both;"></div>
	</div>	
	
	
<?
include('includes/footer.php');
?>